<template>
	<view calss="container">
		<view class="s-padding">
			<view class="s-product-img s-radius-all">
				<s-feng-parse :content="content"></s-feng-parse>
			</view>
		</view>
		<view class="s-safearea-bottom"></view>
		<view class="s-operation">
			<view class="s-operation-left">
				<view class="s-operation-item" hover-class="opcity" :hover-stay-time="150" @tap="lick_index">
					<view class="images_class">
						<s-icon name="shouye" :size="40" color="#333333"></s-icon>
					</view>
					<view class="s-operation-text s-scale-small">首页</view>
				</view>	 
				<view class="s-operation-item" hover-class="opcity" :hover-stay-time="150" @tap="picture_collection">
					<view class="images_class">
						<s-icon v-if="collection_status" name="aixin" :size="40" color="#d81e06"></s-icon>
						<s-icon v-else name="shoucang" :size="40" color="#333333"></s-icon>
					</view>
					<view :class="['s-operation-text','s-scale-small',collection_status?'s-xzd':'']">收藏</view>
				</view>
			</view>
			<view class="s-operation-right" @tap="pic_click">去看直播</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				id:'',
				content:'',
				collection_status:0,
			}
		},
		async onLoad(options) {
			this.id = options.id
			await this.swiperDetail()
		},
		methods: {
			async swiperDetail(){
				const data = await this.$s.model.picture.picDetail({id:this.id})
				this.content = data.content
				this.collection_status = data.collection_status
				this.url = data.url
			},
			//跳转首页
			lick_index(){
				this.$s.uniApi.switchTab({url:'../index/index'})
			},
			//直播收藏
			async picture_collection(){
				const data = await this.$s.model.picture.pictureCollection({
					id:this.id
				})
				if(data.code === 8888){
					this.collection_status = this.collection_status==1?0:1
					this.$s.uniApi.showToast({title: data.msg})
				}
			},
			async pic_click(){
				let customParams = encodeURIComponent(JSON.stringify({ path: 'pages/index/index', pid: 1 }))
				return await this.$s.uniApi.navigateTo({url:this.url+"custom_params="+customParams})
			}
		},
		//下拉刷新
		async onPullDownRefresh() {
		    await this.swiperDetail()
		    uni.stopPullDownRefresh()  
		}
	}
</script>

<style lang="scss" scoped>
	@import 'pic_detall.scss';
</style>
